﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SA1604ElementDocumentationMustHaveSummaryBulbItem.cs" company="StyleCop for ReSharper Development Team">
//   Copyright (c) StyleCop for ReSharper Development Team. All rights reserved.
// </copyright>
// <summary>
//   Defines the SA1604ElementDocumentationMustHaveSummaryBulbItem type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace StyleCop.For.ReSharper.BulbItems.Documentation
{
    #region Using Directives

    using JetBrains.ProjectModel;
    using JetBrains.TextControl;

    using StyleCop.For.ReSharper.BulbItems.Framework;
    using StyleCop.For.ReSharper.CodeCleanup.Rules;

    #endregion

    /// <summary>
    /// BulbItem - SA1604ElementDocumentationMustHaveSummaryBulbItem
    /// Also fixes SA1605PartialElementDocumentationMustHaveSummary.
    /// </summary>
    internal class SA1604ElementDocumentationMustHaveSummaryBulbItem : TransactionalBulbItem
    {
        #region Public Methods

        /// <summary>
        /// Execute inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteInner(ISolution solution, ITextControl textControl)
        {
            var declaration = Utils.GetDeclarationClosestToTextControl(solution, textControl);

            // Fixes SA1604, 1605
            new DocumentationRules().InsertMissingSummaryElement(declaration);
        }

        #endregion
    }
}